package com.msb.search.utils;

import com.msb.common.model.StandardReport;
import com.sun.org.apache.xerces.internal.impl.xpath.regex.REUtil;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

/**
 * @Author: lmf
 * @Create: 2025/3/24 8:28
 * @module
 */
public class SearchUtils {
    /**
     * 索引前缀
     */
    public static final String INDEX_PREFIX = "sms_log_es";


    private static final ThreadLocal<StandardReport> threadLocal = new ThreadLocal<>();

    /**
     * 获取当前查询年份
     */
    public static String getYear() {
        return String.valueOf(LocalDateTime.now().getYear());
    }

    /**
     * 获取当前查询年份索引
     */
    public static String getYearIndex() {
        return INDEX_PREFIX + getYear();
    }


    /**
     * 获取上下文
     */
    public static StandardReport getReport() {
        return threadLocal.get();
    }

    public static void setReport(StandardReport report) {
        threadLocal.set(report);
    }

    public static void removeReport() {
        threadLocal.remove();
    }
}
